<script type="text/html" template>
    <link rel="stylesheet" href="{{ layui.setter.base }}style/css/reset.css">
    <link rel="stylesheet" href="{{ layui.setter.base }}style/css/maintain/google.css">
    <link rel="stylesheet" href="{{ layui.setter.base }}style/page.css">
</script>
<style scoped>
    .layui-form-label {
        width: auto;
        font-size: 10px;
        margin-right: 10px;
    }

    .layui-input {
        width: 150px;
    }
    .boxQuery {
        display: none;
        z-index: 999;
        top: 0;
        position: absolute;
        width: 100%;
        background-color: #ffffff;
        margin: 0 auto;
        padding: 0 0 50px 40px;
        text-align: left;
    }

    .boxQuery .layui-form-item {
        margin: 10px 0;
    }

    .sure {
        width: 70px;
        height: 25px;
        font-size: 11px;
        border-radius: 15px;
        background-color: #FF4C4C;
    }

    .close {
        width: 70px;
        height: 25px;
        border-radius: 15px;
        background-color: #3D8CC9;
    }

    .reset {
        width: 70px;
        height: 25px;
        border-radius: 15px;
        background-color: #FF9F0C;
    }

    .layui-card-body {
        padding: 0;
    }

    .layui-card {
        background-color: transparent;
        border: 0;
        box-shadow: none;
    }
    .box .layui-input{
        width: 90px;
    }
    .mystyle {
        margin-top: 30px;
        display: flex;
        justify-content: flex-start;
        flex-flow: row nowrap;
        align-items: center;
        align-content: flex-start;
        background: #FFF;
        padding: 13px;
        margin-top: 11px;
        margin-bottom: 11px;
    }
    .layui-form-item button{
        display: inline-block;
    }
</style>

<form class="boxQuery layui-form" lay-filter="layuiadmin-form-tags" id="layuiadmin-form-tags">
    <ul class="layui-row">
        <li class="layui-col-md4 layui-col-sm4">
            <div class="flex layui-form-item">
                <label class="layui-form-label">工单状态</label>
                <div class="layui-input-block" style="margin-left: 12px;">
                    <select name="fil05">
                        <option value="">全部</option>
                        <option value="0">未提交</option>
                        <option value="1">待审核</option>
                        <option value="6">OA送审中</option>
                        <option value="9">归档已完成</option>
                    </select>
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 申请日期</label>
                <div class="layui-input-block" style="margin-left: 12px;">
                    <input type="text" style="color: #666;" placeholder="请选择日期" name="fil10" id="time" class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label">新资产编号</label>
                <div class="layui-input-block">
                    <input type="text" style="color: #666;" placeholder="请输入新资产编号" name="tcDetailFia011"
                        class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 原所属公司</label>
                <div class="layui-input-block">
                    <select id="azpa01" name="azpa01" placeholder="请输入原所属公司" lay-search>
                    </select>
                </div>
            </div>
        </li>
        <li class="layui-col-md4 layui-col-sm4">
            <div class="flex layui-form-item">
                <label class="layui-form-label">工单名称</label>
                <div class="layui-input-block" style="margin-left: 19px;">
                    <input type="text" name="tcReqName" placeholder="请输入工单名称" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label">OA流程编号</label>
                <div class="layui-input-block">
                    <input type="text" name="fil02" placeholder="请输入OA流程编号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 设备编号</label>
                <div class="layui-input-block" style="margin-left: 19px;">
                    <input type="text" name="fil03" placeholder="请输入设备编号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 拟调往公司</label>
                <div class="layui-input-block" style="margin-left: 8px;">
                    <select id="azpb01" name="azpb01" placeholder="请输入拟调往公司" lay-search>
                    </select>
                </div>
            </div>
        </li>
        <li class="layui-col-md4 layui-col-sm4">
            <div class="flex layui-form-item">
                <label class="layui-form-label">工单编号</label>
                <div class="layui-input-block" style="margin-left: 11px;">
                    <input type="text" name="fil01" placeholder="请输入工单编号" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 申请人工号</label>
                <div class="layui-input-block">
                    <input type="text" name="gen01" placeholder="请输入申请人工号" autocomplete="off" class="layui-input" id="gen02">
                </div>
            </div>
            <div class="flex layui-form-item">
                <label class="layui-form-label"> 原资产编号</label>
                <div class="layui-input-block">
                    <input type="text" style="color: #666;" placeholder="请输入原资产编号" name="fia011" class="layui-input">
                </div>
            </div>
        </li>
    </ul>
    <div class="footer layui-btn-container" style="justify-content: center">
        <button lay-submit lay-filter="LAY-submit" class="sure layui-btn layui-btn-radius layui-btn-primary">
            确定
        </button>
        <button class="close layui-btn layui-btn-radius layui-btn-primary">
            关闭
        </button>
        <button class="reset layui-btn layui-btn-radius layui-btn-primary">
            清空
        </button>
    </div>
</form>
<div class="layui-card box">
    <div class="layuiadmin-card-header-auto" style="border: none;">
        <div class="layui-fluid layui-row">
            <div class="layui-form  layuiadmin-card-header-auto" style="border: none;" lay-filter="app-content-comment">
                <div class="layui-btn-container layui-col-sm12 layui-col-md12">
                    <button class="add-btn search-two-btn" data-type="add">
                        <i class="layui-icon layui-icon-add-circle" style="font-size: 15px; color: #1E9FFF;"></i>
                        <span> 调拨工单</span>
                    </button>
                </div>
                <div class="layui-form-item mystyle">
                    <div class="layui-form-item layui-col-sm2 layui-col-md2">
                        <label class="layui-form-label">工单状态:</label>
                        <div class="layui-input-block ">
                            <select name="fil05">
                                <option value="">全部</option>
                                <option value="0">未提交</option>
                                <option value="1">待审核</option>
                                <option value="6">OA送审中</option>
                                <option value="9">归档已完成</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-sm2 layui-col-md2">
                        <label class="layui-form-label">工单编号:</label>
                        <div class="layui-input-block ">
                            <input type="text" name="fil01"  autocomplete="off"
                                class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-sm3 layui-col-md3">
                        <label class="layui-form-label">申请时间:</label>
                        <div class="layui-input-block ">
                            <input type="text" placeholder="请选择日期"
                                name="fil10" id="time1" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item layui-col-sm4 layui-col-md4" style="text-align: right;">
                        <button class="search-two-btn layui-btn-radius" lay-submit lay-filter="LAY-app-order-search"
                            style="background-color:#4C96CF;">
                            <i class="layui-icon layui-icon-search" style="font-size: 10px; color: #FFF;"></i>
                            <span>查询</span>
                        </button>
                        <button class="search-two-btn layui-btn-radius" data-type="query" style="cursor: pointer;">
                            <span>条件查询</span>
                        </button>
                    </div>
                </div>
            </div>
            <div class="layui-card-body">
                <table class="layui-table" id="LAY-app-content-comm" lay-filter="LAY-app-content-comm">
                </table>
                <div class="footer layui-btn-container">
                    <button class="search layui-btn layui-btn-radius layui-btn-primary" style="background:red;">
                        <i class="layui-icon layui-icon-delete" style="font-size: 15px; color: #FFF;"></i>
                        <span class="labelinp" data_cn="打印" data_en="print" data-lang="toggle">删除</span>
                    </button>
                </div>
            </div>
        </div>

    </div>
</div>
<script type="text/html" id="buttonTpl">
    {{# if(d.fil05 == "0"){ }}
    <span>未提交</span> 
    {{# } else if(d.fil05 == "1"){ }}
    <span>待审核</span> 
    {{# } else if(d.fil05 == "2"){ }}
    <span>待执行</span> 
    {{# } else if(d.fil05 == "6"){ }}
    <span>OA送审中</span>
    {{# } else if(d.fil05 == "9"){ }}
    <span>归档已完成</span>
     {{# } }}
</script>
<script>
    layui.use(['admin', 'form', 'user', 'table', 'api', 'laytpl', 'utill', 'laydate'], function () {
        var $ = layui.$,
            admin = layui.admin,
            view = layui.view,
            api = layui.api,
            table = layui.table,
            setter = layui.setter,
            laytpl = layui.laytpl,
            utill = layui.utill,
            laydate = layui.laydate,
            form = layui.form;
        utill.showAndHide('.add-btn',"FilFileController:insertFilFileMove");
        form.render(null, 'app-content-comment');
        form.on('submit(LAY-app-order-search)', function (data) {
            var field = data.field;
            rander(field)
        });
        laydate.render({
            elem: `#time1`,
            done: function (value, date, endDate) { }
        });

        form.render(null, 'layuiadmin-form-tags');
        admin.req({
            url: api.host + api.selectAzpEx,
            type: "POST",
            done: function (res) {
                var str = '<option value=""></option>'
                var str1 = '<option value=""></option>'
                for (let index = 0; index < res.data.length; index++) {
                    str1 = str1 +
                        `<option value="${res.data[index].azp01}">${res.data[index].azp02}</option>`
                    str = str +
                        `<option value="${res.data[index].azp01}">${res.data[index].azp02}</option>`
                }
                $('#azpa01').append(str)
                $('#azpb01').append(str1)
                form.render(null, 'layuiadmin-form-tags');
            }
        });
        // admin.req({
        //     url: api.host + api.selectApplyer,
        //     type: "POST",
        //     done: function (res) {


        //         var str = '<option value=""></option>'
        //         for (let index = 0; index < res.data.length; index++) {
        //             if (res.data[index].fia011) {
        //                 str = str +
        //                     `<option value="${res.data[index].gen01}">${res.data[index].gen02}</option>`
        //             }

        //         }

        //         $('#gen01').append(str)
        //         form.render(null, 'layuiadmin-form-tags');
        //     }
        // });
        admin.req({
            url: api.host + api.selectApplyer,
            type: "POST",
            done: function (res) {
                var str = '<option value=""></option>'
                for (let index = 0; index < res.data.length; index++) {
                    str = str +
                        `<option value="${res.data[index].gen01}">${res.data[index].gen02}</option>`
                }
                $('#gen02').append(str)
                form.render(null, 'layuiadmin-form-tags');
            }
        });
        laydate.render({
            elem: `#time`,
            done: function (value, date, endDate) { }
        });
        rander()
        function rander(field) {
            //列定制的
            var _llp = {
                fil05: function (d) {
                    if (d.fil05 == 0) {
                        return "<span>未提交</span>";
                    } else if (d.fil05 == 1) {
                        return "<span>待审核</span>";
                    } else if (d.fil05 == 2) {
                        return "<span>待执行</span> ";
                    } else if (d.fil05 == 6) {
                        return "<span>OA送审中</span>";
                    }else if (d.fil05 == 9) {
                        return "<span>归档已完成</span>";
                    } else {
                        return "";
                    }
                }
            }
            //列定制
            utill.columnCustom('#LAY-app-content-comm', "FilFileDBListVO", {
                url: api.host + api.FilFileDBSelectFilFile,
                where: field,
                templet: _llp
            });
            table.on('tool(LAY-app-content-comm)', function (obj) {
                var data = obj.data;
                if (obj.event == 'detail'){
                    if (obj.data.fil05 == 6 || obj.data.fil05 == 9) {
                        location.hash = '/transaction/branch-one/form-one/id=' + obj.data.tcReqId +
                            '/' + 'fil01=' + obj.data.fil01;
                        var href = '[data-jump="transaction/balance"]';
                        sessionStorage.setItem('layui-this', JSON.stringify(href));
                    } else if (obj.data.fil05 == 0) {
                        location.hash = '/transaction/branch-one/form-one-bc/id=' + obj.data.tcReqId +
                            '/' + 'fil01=' + obj.data.fil01; 
                        var href = '[data-jump="transaction/balance"]';
                        sessionStorage.setItem('layui-this', JSON.stringify(href));
                    }
                }
            })
        }
        form.verify({
            num:[
                /^[\S]{8,99}$/,'请输入申请人工号最少八位,且不能出现空格'
            ]
        })
        var active = {
            query: function () {
                $('.sure').click(function(){
                    let val1 = $('#gen02').val()
                    $('#gen02').removeAttr('lay-verify');
                    if(val1 == ''){        
                    }else if(val1 != ''){
                        $('#gen02').attr('lay-verify','num');
                    }
                })
                $('.boxQuery').css("display", "block");
                // 高查弹窗关闭
                $('.close').click(function(){
                    $('#gen02').removeAttr('lay-verify');
                    $(".boxQuery").css("display", "none");
                });
                $('.reset').click(function(){
                    $('#gen02').removeAttr('lay-verify');
                    $("#layuiadmin-form-tags")[0].reset();
                    layui.form.render();
                });
                form.on('submit(LAY-submit)', function (data) {
                    var field = data.field; //获取提交的字段
                    rander(field)
                    $(".boxQuery").css("display", "none");
                    return false;
                });
            },
            add: function () {
                location.hash = '/transaction/branch-one/add_form'
            }
        }
        //删除按钮
        $('.footer').on('click', '.search', function () {
            var checkStatus = table.checkStatus('#LAY-app-content-comm').data;
            var fil01 = [];
            var fil05 = [];
            checkStatus.forEach(elem => {
                fil01.push(elem.fil01);
                fil05.push(elem.fil05);
            })
            if (fil05 && fil01 == '' || fil05 && fil01 == null) {
                layer.msg('请选择您要删除的工单!')
            } else {
                admin.req({
                    url: api.host + api.sbdb.del,
                    contentType: 'application/json',
                    dataType: 'json',
                    type: 'post',
                    data: JSON.stringify({ fil05: fil05, fil01: fil01 }),
                    success: function (res) {
                        if (res.data == 0) {
                            table.render()
                            table.reload('#LAY-app-content-comm');
                        }
                    }
                });
            }
        })
        $('.search-two-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>